<div class="componentheading"><?php echo $page_title;?></div>
<div><?php global_message(); ?></div>
<?php
	$isEdit = isset($_member) ? true : false;
	$text = empty($isEdit) ? 'Add' : 'Update';
	$selected = 'selected = "selected"';
?>
<form method="post" id="newForm">
<div class="box-header">New Member</div>
<div class="box table">
<table width="100%">
    <tr>
        <td width="25%"><strong>First Name</strong></td>
        <td width="75%"><input type="text" class="required" name="first_name" id="first_name" value="<?php if($isEdit) echo $_member->first_name;?>" /></td>
    </tr>
    <tr>
    	<td><strong>Last Name</strong></td>
        <td><input type="text" class="required" name="last_name" id="last_name" value="<?php if($isEdit) echo $_member->last_name;?>" /></td>
    </tr>
    <tr>
    	<td><strong>Email</strong></td>
        <td><input type="text" class="required email" name="email" id="email" value="<?php if($isEdit) echo $_member->email;?>" /></td>
    </tr>
    <tr>
    	<td><strong>Address1</strong></td>
        <td><input type="text" class="required" name="address1" id="address1" value="<?php if($isEdit) echo $_member->address1;?>" /></td>
    </tr>
    <tr>
    	<td><strong>Address2</strong></td>
        <td><input type="text" class="" name="address2" id="address2" value="<?php if($isEdit) echo $_member->address2;?>" /></td>
    </tr>
    <tr>
    	<td><strong>Phone1</strong></td>
        <td><input type="text" class="required" name="phone1" id="phone1" value="<?php if($isEdit) echo $_member->phone1;?>" /></td>
    </tr>
    <tr>
    	<td><strong>Phone2</strong></td>
        <td><input type="text" class="" name="phone2" id="phone2" value="<?php if($isEdit) echo $_member->phone2;?>" /></td>
    </tr>
    <tr>
    	<td><strong>Status</strong></td>
        <td>
            <select name="status" id="status">
                <option value="active">Active</option>
                <option value="suspended">Suspended</option>
            </select>
        </td>
    </tr>
    <tr>
    	<td>&nbsp;</td>
        <td>
            <input type="submit" name="submit_member" id="submit_member" value="<?php echo $text;?>">
            <input type="button" onclick="window.member.href = '<?php echo site_url('member');?>'" value="Back" />
        </td>
    </tr>
</table>
</div>
</form>
<script>
$(document).ready(function(){
	//initialize jquery validation
	$('#newForm').validate({
                    rules:
                    {
                        email:
                        {
                            remote:
                            {
                                url: "<?php echo site_url("member/check_email");?>",
                                type: "post"
                            }
                            }
                    },
                    messages:
                    {
                        email:
                        {
                            remote: "Email already exists"
                        }
                    }
                });
								
});

</script>
